// 供应商列表
import React from 'react';
import { Select } from 'antd';
import { connect } from 'dva';

const { Option } = Select;

@connect(({ addemprec: { supplyList }, loading }) => ({
  supplyList,
  loading: loading.effects['addemprec/fetchSupplyList'],
}))
class Supplier extends React.Component {
  componentDidMount() {
    const { dispatch, params } = this.props;
    dispatch({
      type: 'addemprec/fetchSupplyList',
      payload: { name: null, ...params },
    });
  }

  getData = () => {};

  render() {
    const { supplyList = [], getData = this.getData } = this.props;
    return (
      <Select
        placeholder="请输入关键字检索"
        {...this.props}
        showSearch
        optionFilterProp="children"
        notFoundContent="暂无数据"
        onSelect={(value, options) => getData(value, options)}
      >
        {supplyList.map(item => (
          <Option key={item.suppId}>{item.name}</Option>
        ))}
      </Select>
    );
  }
}
export default Supplier;
